#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

struct TreeNode {
       int val;
       TreeNode *left;
       TreeNode *right;
       TreeNode(int x) : val(x), left(NULL), right(NULL) {}
     };
//https://leetcode-cn.com/problems/er-cha-shu-zhong-he-wei-mou-yi-zhi-de-lu-jing-lcof/solution/mian-shi-ti-34-er-cha-shu-zhong-he-wei-mou-yi-zh-5/
class Solution {
public:
    vector<vector<int>> ans;
    vector<int> path;

    vector<vector<int>> pathSum(TreeNode* root, int sum) {
        if(root== nullptr) return ans;
        recur(root,sum);
        return ans;
    }
    void recur(TreeNode* root,int sum){
        if(root==nullptr) return;
        path.push_back(root->val);
        sum -= root->val;
        if(sum==0&&root->left== nullptr&&root->right== nullptr) ans.push_back(path);
        recur(root->left,sum);
        recur(root->right,sum);
        path.erase(path.end()-1);
    }
};

int main(){

}